<?php
namespace Admin\Controller;

use Think\Controller;
use Think\Verify;
class LoginController extends Controller{
	public function login(){
		if(IS_POST){
			$model=D('Admin');
			
			if($model->create($_POST,4)){
				$ret=$model->login();
				if($ret===TRUE){
					$this->success('登陆成功',U('Admin/Index/index'));
					exit;
				}else{
					$ret==1 ? $this->error('用户名不存在！')  :  $this->error('密码错误！');
				}
			}else{
				$this->error($model->getError());
			}
		}
		$this->display();
	}
	public function verify(){
		$config =    array(				
				'length'      =>    4,     // 验证码位数
				'useNoise'    =>    true, // 关闭验证码杂点
				'useImgBg '	  =>    true,
				//'useZh'		  =>	true,
				//'imageH'   => 30, // 验证码图片高度
				//'imageW'   => 30, // 验证码图片宽度
		);
		$verify=new Verify($config);
		$verify->entry();
	}
	public function logout(){
		$model=D('Admin');
		$model->logout();
		$this->success('退出成功',U('Login/login'));
	}
}